<!-- 中英文切换 -->
<template>
  <div class="box">
    <el-dropdown trigger="click">
      <span class="languageText">
        {{languageText}}<i class="el-icon-arrow-down el-icon--right"></i>
      </span>
      <el-dropdown-menu slot="dropdown">
        <el-dropdown-item @click.native="switchLan('English')">English</el-dropdown-item>
        <el-dropdown-item @click.native="switchLan('中文')">中文</el-dropdown-item>
      </el-dropdown-menu>
    </el-dropdown>
  </div>
</template>
<script>
export default {
  data () {
    return {
      languageText: localStorage.getItem('languageSet') ? localStorage.getItem('languageSet') === 'zh' ? '中文' : 'English' : 'English'
    }
  },
  methods: {
    switchLan (val) {
      this.languageText = val
      const languageCode = this.languageText === '中文' ? 'zh' : 'en'
      localStorage.setItem('languageSet', languageCode)
      window.location.reload()
    }
  }
}
</script>
<style scoped>
.box {
  display: inline-block;
}
.languageText {
  color: #fff;
  font-size: 16px;
  cursor: pointer;
}
</style>